//计算数组元素的标准差
function getVariance(cityObj){
  let attributeArr=new Array();//字段名
  let valueArr=new Array();//字段值
  let totalScore=0;
  for(x in cityObj['jsonInfo']){
    if(x==="cityName")
      continue;
    attributeArr.push(x);
    totalScore+=cityObj.jsonInfo[x];
    valueArr.push(cityObj.jsonInfo[x])
  }
  //求取平均值
  let average=totalScore/valueArr.length;
  //计算方差
  let temp =0;
  for(x in valueArr){
     temp += Math.pow((x-average),2);
  }
  variance=temp/valueArr.length;
  return Math.pow(variance,0.5).toFixed(3);//返回标准差
}

//JSON对象的冒泡排序
function bubbleJson(jsonArr,sortAttribute){
  let i,j,temp;
  for(i=0;i<jsonArr.length-1;i++){
    for(j=0;j<jsonArr.length-1-i;j++){
      if(jsonArr[j][sortAttribute]>jsonArr[j+1][sortAttribute]){
        temp=jsonArr[j];
        jsonArr[j]=jsonArr[j+1];
        jsonArr[j+1]=temp;
      }
    }
  }
  return jsonArr;
}